import { request } from '@umijs/max';

// 用户登录
export async function userLogin(data: { username: string; password: string }) {
  return await request('/auth/login/', { method: 'POST', data });
}

// 获取当前用户信息
export async function getCurrentUser() {
  return await request('/auth/users/me/');
}

// 获取用户列表
export async function getUsers(params?: any) {
  return await request('/auth/users/', { params });
}

// 获取用户详情
export async function getUserDetail(id: number) {
  return await request(`/auth/users/${id}/`);
}

// 创建用户
export async function createUser(data: any) {
  return await request('/auth/users/', { method: 'POST', data });
}

// 更新用户
export async function updateUser(id: number, data: any) {
  return await request(`/auth/users/${id}/`, { method: 'PUT', data });
}

// 删除用户
export async function deleteUser(id: number) {
  return await request(`/auth/users/${id}/`, { method: 'delete' });
}

// 修改密码
export async function changePassword(data: any) {
  return await request('/auth/users/change_password/', { method: 'POST', data });
}